<?php

require_once('../include/GeneralTop.php');
require('../include/class/db.php');
require("../include/lib/fckeditor/fckeditor.php");

if (!$content_admin) {
	die('<div style="text-align:center">Permission denied...</div>');
}

if ((isset($_POST["submit"]))) {
    $db = new db;
    $insertSQL = sprintf("INSERT INTO newsinfo (NTitle, NBody, NType, NAuthor, NDate, source, pub_date) VALUES (%s, %s, %s, %s, now(), %s, %s)",
                       GetSQLValueString($_POST['NTitle'], "text"),
                       GetSQLValueString(stripslashes($_POST['FCKeditor1']), "text"),
                       GetSQLValueString($_POST['NType'], "text"),
                       GetSQLValueString($_POST['NAuthor'], "text"),
                       GetSQLValueString($_POST['source'], "text"),
                       GetSQLValueString($_POST['pub_date'], "text")
                       );

    $db->query($insertSQL);
    header("location:".$_SERVER['PHP_SELF']."?result=suc");
}

include('AdminPanel.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加新闻</title>
<script src="../include/js/calendar.js" type="text/javascript"></script>
</head>

<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form1" id="form1">
  <table align="center" width="70%">
    <?php
    if($_GET['result'] && 'suc' == $_GET['result']) {
    ?>
    <tr valign="baseline">
      <td colspan="2" nowrap="nowrap" align="center"><font color="green">添加新闻成功...</font></td>
    </tr>
    <?php
    }
    ?>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">标题:</td>
      <td><input type="text" name="NTitle" value="" size="32" /></td>
    </tr>    
    <tr valign="baseline">
      <td nowrap="nowrap" align="right" valign="top">内容:</td>
      <td>
      <?php
	  $oFCKeditor = new FCKeditor('FCKeditor1') ;
	  $oFCKeditor->BasePath = FCKEDITOR_BASE_PATH;
	  $oFCKeditor->Height = 400;
	  $oFCKeditor->Create();
	  ?>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">新闻类型:</td>
      <td>
		<select name="NType">
		  <option value="-1">--请选择--</option>     
	      <option value="<?php echo NEWS_BRANCH?>" <?php echo $select1?>>分会新闻</option>
	      <option value="<?php echo NEWS_PET_PRO?>" <?php echo $select2?>>动保新闻</option>
	    </select>
	  </td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">作者:</td>
      <td><input type="text" name="NAuthor" value="" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">新闻来源:</td>
      <td><input type="text" name="source" value="" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">发表日期:</td>
      <td>
      	<input type="text" name="pub_date" id="pub_date" value="" size="32" />
      	<img src="../images/calendar.ico" width="25" height="25" onclick="fPopCalendar(event,this,document.getElementById('pub_date'))" style="cursor:pointer;">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td>
      	<input type="submit" name="submit" id="submit" value="Insert record" />&nbsp;&nbsp;
      	<input type="button" id="button" onclick="window.location.href='ShowNews.php'" value="Back">
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>